package com.zy.dao.impl;

import com.zy.dao.ClearCarDao;
import com.zy.utils.JdbcUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class ClearCarDaoImpl implements ClearCarDao {
    @Override
    public boolean clearCarByUserId(int userId) {
        String sql = "DELETE FROM tb_car WHERE user_id = ?";
        try (Connection connection = JdbcUtil.getConnection();
             PreparedStatement stmt = connection.prepareStatement(sql)) {
            stmt.setInt(1, userId);
            return stmt.executeUpdate() > 0;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }
}